#include<bits/stdc++.h>
using namespace std;
int n,l,r,ans,maxn,ys;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	maxn=n-1;
	ys=l%n;
	if(ys+(r-l)>=maxn) printf("%d",maxn);
	else printf("%d",ys+(r-l));
	
	return 0;
}
